package TEST3;

public class A02 {
    public static void main(String[] args) {
        Animal an=null;
        an=new Cat();
        an.m_name="猫";
        an.shout();
        an=new Dog();
        an.m_name="狗";
        an.shout();
        an=new Sheep();
        an.m_name="羊";
        an.shout();
    }
}
abstract class Animal {
    protected String m_name;
    protected abstract void shout();
}
class Cat extends Animal {
    protected void shout() {
        System.out.println(m_name+"：喵喵~~");
    }
}
class Dog extends Animal {
    protected void shout() {
        System.out.println(m_name+"：旺旺~~");
    }
}
class Sheep extends Animal {
    protected void shout() {
        System.out.println(m_name+"：咩咩~~");
    }
}
